//
//  MainViewController.swift
//  SHWB
//
//  Created by Shawn on 16/4/3.
//  Copyright © 2016年 Shawn. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewController(HomeTableViewController(),title: "首页",imageName: "tabbar_home")
         addChildViewController(MessageTableViewController(),title: "消息",imageName: "tabbar_message_center")
         addChildViewController(DiscoverTableViewController(),title: "发现",imageName: "tabbar_home")
         addChildViewController(ProfileTableViewController(),title: "我",imageName: "tabbar_home")
        
    }

  private  func addChildViewController(childVc: UIViewController ,title:String ,imageName:String) {
        
        //1.设置子控制器属性
        childVc.title = title
        childVc.tabBarItem.image = UIImage(named: imageName)
        childVc.tabBarItem.selectedImage = UIImage(named: imageName + "_highlighted")
        
        //2.包装导航控制器
        let childNav  = UINavigationController(rootViewController: childVc)
        
        //3.添加控制器
        addChildViewController(childNav)
    }

}
